//
//  IconLabel.m
//  Test
//
//  Created by Alimjan on 15/12/30.
//  Copyright © 2015年 Alimjan. All rights reserved.
//

#import "IconLabel.h"
#include <stdio.h> 
#include <wchar.h>
#import <UyghurSDK_iOS/UyghurSDK_iOS.h>
@implementation IconLabel

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
       [self initView];
    }
    return self;
}
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self initView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        [self initView];
    }
    return self;
}

-(void) initView{
    UIFont *font = [UIFont fontWithName:@"jula" size:300.0];
    self.font = font;
}
-(NSString*)getStringFromWChar:(const wchar_t*) inStr

{
    
    NSString *str = [[NSString alloc] initWithBytes:inStr length:
                     4 encoding:NSUTF32LittleEndianStringEncoding];
    return str;
    
}
//- (ini)
-(void)setHexText:(NSString*)hexText{
    
    wchar_t w = (wchar_t)strtoul([hexText UTF8String],0,16);
    NSString *s = [self getStringFromWChar:&w];
    
    UIFont *font = [UIFont fontWithName:@"jula" size:300];
    CGSize size = [s sizeWithAttributes:@{NSFontAttributeName:font}];
    CGFloat scale = size.width/self.frame.size.width;
    font = [UIFont fontWithName:@"jula" size:300.0/scale];
    self.font = font;
    [super setText:s];
}
-(void)setDecText:(int)decText{
    //    char c = (char)hexText;
    wchar_t w = (wchar_t)decText;
    NSString *s = [self getStringFromWChar:&w];
    [super setText:s];
    UIFont *font = [UIFont fontWithName:@"jula" size:300];
    CGSize size = [s sizeWithAttributes:@{NSFontAttributeName:font}];
    CGFloat scale = size.width/self.frame.size.width;
    font = [UIFont fontWithName:@"jula" size:300.0/scale];
    self.font = font;
}

@end
